<template>
  <div class="register-container">
    <el-form
      ref="registerForm"
      :model="registerForm"
      :rules="registerRules"
      class="register-form"
      autocomplete="on"
      label-position="top"
    >
      <el-form-item prop="username">
              <span class="svg-container">
                <svg-icon icon-class="wechat" />
              </span>
        <el-input
          ref="username"
          v-model="registerForm.username"
          placeholder="用户名"
          name="username"
          type="text"
          tabindex="1"
          auto-complete="on"
        />
      </el-form-item>
      <el-form-item prop="name">
              <span class="svg-container">
                <svg-icon icon-class="user" />
              </span>
        <el-input
          ref="name"
          v-model="registerForm.name"
          placeholder="姓名"
          name="name"
          type="text"
          tabindex="1"
          auto-complete="on"
        />
      </el-form-item>
      <el-form-item prop="email">
              <span class="svg-container">
                <svg-icon icon-class="email" />
              </span>
        <el-input
          ref="email"
          v-model="registerForm.email"
          placeholder="邮箱号"
          name="email"
          type="text"
          tabindex="1"
          auto-complete="on"
        />
      </el-form-item>
      <el-form-item prop="password">
              <span class="svg-container">
                <svg-icon icon-class="password" />
              </span>
        <el-input
          :key="passwordType"
          ref="password"
          v-model="registerForm.password"
          :type="passwordType"
          placeholder="密码"
          name="password"
          tabindex="2"
          auto-complete="on"
          @keyup.enter.native="handleLogin"
        />
        <span class="show-pwd" @click="showPwd">
                <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
              </span>
      </el-form-item>
      <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleRegister">提交</el-button>
    </el-form>
  </div>
</template>

<script>
import { Component, Vue } from 'vue-property-decorator'
import { isValidUsername } from '@/utils/validate'

@Component({
  name: 'Register'
})
export default class extends Vue {
  registerForm = {
    username: 'admin',
    password: '111111'
  }

  registerRules = {
  }
}
</script>

<style scoped>
.register-container {
  margin: 20px 0;
  .register-form {
    display: inline-block;
    cursor: pointer;
  }
  .svg-container {
    color: #fff;
    font-size: 24px;
    margin-top: 8px;
  }
}
</style>
